/*******************************************************************************
** 文件名称：timer0.c
** 文件作用：TC0操作
** 编写作者：TomFree <付瑞彪>
** 编写时间：2019-12-20
** 文件备注：
**
** 更新记录：
**           2019-12-20 -> 创建文件                                 <Tom Free>
**
**           1 Tab == 4 Spaces     UTF-8     ANSI C Language
*******************************************************************************/

#include "timer0.h"

void TIMER0_Init(
#if (CHIP_TYPE != 8)
				 TIMER0_MODE mode,

#if	((CHIP_TYPE == 48)||(CHIP_TYPE == 88)||(CHIP_TYPE == 168))
				 TIMER0_OUTPUT_MODE omodea,
				 TIMER0_OUTPUT_MODE omodeb,
#else
				 TIMER0_OUTPUT_MODE omode,
#endif
				 
#endif
				 TIMER0_COLOK clock,
				 TIMER0_INTERRUPT inten)
{
	TCNT0  = 0x00;
	TIMSK0 |= (inten);
#if (CHIP_TYPE != 8)
	
#if	((CHIP_TYPE == 48)||(CHIP_TYPE == 88)||(CHIP_TYPE == 168))
	OCR0A  = 0X00;
	OCR0B  = 0X00;
	TCCR0A = (omodea<<6)|(omodeb<<4)|(mode&0X03);
	TCCR0B = ((mode&0x04)<<1)|clock;
#else
	OCR0   = 0x00;
	TCCR0  =((mode&0x01)<<6)|((mode&0x02)<<2)|(omode<<4)|(clock);
#endif

#else
	TCCR0 = clock;
#endif
}

void TIMER0_ColokSet(TIMER0_COLOK clock)
{
#if	((CHIP_TYPE == 48)||(CHIP_TYPE == 88)||(CHIP_TYPE == 168))
	TCCR0B |= clock;
#else
	TCCR0 |= clock;
#endif
}

void TIMER0_SetTCNT0(GM_U8 tcnt0)
{
	TCNT0  = tcnt0;
}

#if (CHIP_TYPE != 8)

#if	((CHIP_TYPE == 48)||(CHIP_TYPE == 88)||(CHIP_TYPE == 168))
void TIMER0_SetOCR0A(GM_U8 ocr0a)
{
	OCR0A  = ocr0a;
}

void TIMER0_SetOCR0B(GM_U8 ocr0b)
{
	OCR0B  = ocr0b;
}
#else
void TIMER0_SetOCR0(GM_U8 ocr0)
{
	OCR0   = ocr0;
}
#endif


#endif


